﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Demo.Framework.Problems.Percolation
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = 5;
            int count = (int)Math.Pow(N, 2) - 1;
            var rnd = new Random();

            Grid g = new Grid(N);
            long counter = 0;

            while (!g.IsPercolating())
            {
                int p = rnd.Next(0, count);                
                if (g.Open(p))
                {
                    //Console.WriteLine("Opening Node : {0} ...", p);
                    counter++;
                }               
            }

            double percolation = (counter / N) * 100;
            Console.WriteLine("Percolation : {0}", percolation);

            Console.Read();
        }
    }
}
